package com.aaa.market.controller;

import com.aaa.common.util.Result;
import com.aaa.market.entity.CustomerIssues;
import com.aaa.market.service.CustomerIssuesService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;

/**
 * (CustomerIssues)表控制层
 *
 * @author YuXin
 * @since 2020-11-25 16:36:44
 */
@RestController
@RequestMapping("customerIssues")
public class CustomerIssuesController {
    /**
     * 服务对象
     */
    @Resource
    private CustomerIssuesService customerIssuesService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("queryById")
    public CustomerIssues queryById(Integer id) {
        return this.customerIssuesService.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param pageNo         查询当前页
     * @param pageSize       查询每页条数
     * @param customerIssues 对象实体
     * @return 对象列表
     */
    @GetMapping("queryAllByParam")
    public Result queryAllByParam(Integer pageNo, Integer pageSize, CustomerIssues customerIssues) {
        return this.customerIssuesService.queryAllByParam(pageNo, pageSize, customerIssues);
    }

    /**
     * 查询多条数据
     *
     * @return 对象列表
     */
    @PostMapping("queryAll")
    public Result queryAll(@RequestBody CustomerIssues customerIssues) {
        return this.customerIssuesService.queryAll(customerIssues);
    }

    /**
     * 查询多条数据
     *
     * @return 对象列表
     */
    @GetMapping("queryAllSubmodule")
    public Result queryAllSubmodule() {
        return this.customerIssuesService.queryAllSubmodule();
    }

    /**
     * 新增数据
     *
     * @param customerIssues 实例对象
     * @return 实例对象
     */
    @PostMapping("insert")
    public CustomerIssues insert(@RequestBody CustomerIssues customerIssues) {
        customerIssues.setAddtime(new Date());
        this.customerIssuesService.insert(customerIssues);
        return customerIssues;
    }

    /**
     * 修改数据
     *
     * @param customerIssues 实例对象
     * @return 实例对象
     */
    @PutMapping("update")
    public CustomerIssues update(@RequestBody CustomerIssues customerIssues) {
        return this.customerIssuesService.update(customerIssues);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @DeleteMapping("deleteById")
    public boolean deleteById(Integer id) {
        return this.customerIssuesService.deleteById(id);
    }
}